<template >
    <DIV class="bg_write"
        v-loading="loading">
        <el-row>
            <el-col :span="24"
                class="content_title clearfix">
                <el-col :span="12">
                    <HeadTitle></HeadTitle>
                </el-col>
                <el-col :span="12">
                </el-col>
            </el-col>
        </el-row>

        <el-row></el-row>                  
        <div class="content_edit">
            <div class="black">
                <h5>基本信息</h5>
                <div class="add_con_form info">
                    <ul style="">
                        <li><span>订单号：</span> {{this.data.oid}}</li>
                        <li><span>用户昵称：</span> {{this.data.nickname}}</li>
                        <li><span>用户名：</span> {{this.data.username}}</li>
                        <li><span>产品名称：</span>{{this.data.title}}</li>
                        <li><span>订单状态：</span> {{orderStatus(this.data.status)}}</li>
                        <li><span>入单时间：</span> {{this.data.created_time | getTimeFormat}}</li>
                        <li><span>订单金额：</span> {{this.data.money}}</li>
                        <li><span>收益时间：</span> {{this.data.income_time | getTimeFormat}}</li>
                        <li><span>收益：</span> {{this.data.income}}</li>
                    </ul>
                    <div class="blank"></div>
                </div>
            </div>
        </div>
        <div class="blank"></div>
        <div class="black">
            <el-row>
                <el-col :span="24"
                    class="pd_20">
                    <el-table ref="multipleTable"
                        :data="moneylist"
                        border
                        tooltip-effect="dark"
                        style="width: 99.8%">
                        <el-table-column label="会员账号"
                            min-width="50">
                            <template slot-scope="scope">{{ scope.row.username }}</template>
                        </el-table-column>

                        <el-table-column label="会员昵称"
                            min-width="50">
                            <template slot-scope="scope">{{ scope.row.nickname }}</template>
                        </el-table-column>

                        <el-table-column label="订单号"
                            min-width="60">
                            <template slot-scope="scope">{{ scope.row.oid}}</template>
                        </el-table-column>

                        <el-table-column label="积分/现金"
                            min-width="50">
                            <template slot-scope="scope">{{ scope.row.money | keepTwoNum }}
                                {{scope.row.style_cn}}</template>
                        </el-table-column>

                        <el-table-column label="时间"
                            min-width="50">
                            <template
                                slot-scope="scope">{{ scope.row.created_time |getTimeFormat }}</template>
                        </el-table-column>

                        <el-table-column label="剩余积分/现金"
                            min-width="50">
                            <template slot-scope="scope">{{ scope.row.balance | keepTwoNum }}
                                {{scope.row.style_cn}}</template>
                        </el-table-column>

                        <el-table-column label="交易类型"
                            min-width="30">
                            <template slot-scope="scope">{{ scope.row.style }}</template>
                        </el-table-column>
                    </el-table>
                </el-col>
            </el-row>
        </div>
    </div>
</template>


<script>
import HeadTitle from "@/components/currency/HeadTitle.vue";
export default {
  components: {
    HeadTitle
  },
  data() {
    return {
      data: {},
      moneylist: [],
      loading: false,
    };
  },
  methods: {
    orderStatus(status) {
      let str = "";
      switch (status) {
        case "0":
          str = "未支付";
          break;
        case "1":
          str = "已支付";
          break;
        case "2":
          str = "已完成";
          break;
        default:
          str = "未知";
          break;
      }
      return str;
    },

    getOrderDetail(id) {
      this.loading = true;
      var params = {};
      params["id"] = id;
      this.$api.getDapp.getDappOrderDetail(params).then(res => {
        if (res.data.code == 200) {
          this.data = res.data.result;
          console.log(res.data.result);
          this.getMoneyList(res.data.result.oid);
        }
        this.loading = false;
      });
    },

    getMoneyList(oid) {
      var data = {};
      data["oid"] = oid;
      this.$api.getUser.orderMoneyList(data).then(res => {
        if (res.data.status == 1 && res.data.code == 200) {
          this.moneylist = res.data.result;
        } else {
          this.$fnc.alertError(res.data.result);
        }
      });
    }
  },
  beforeCreate() {
    this.loading = true; //数据未加载之前调用loading
  },
  created() {
    this.loading = false;
  },
  computed: {},
  watch: {},
  mounted() {
    // console.log(this.$route.query.id)
    this.getOrderDetail(this.$route.query.id);
  }
};
</script>

<style lang="less" scoped>
</style>
